package bishi.day14_5_10;

import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

/**
 * @author 是阿秋啊
 * @date 2022/05/10 10:01
 **/
public class year_days {
    static Map<Integer, Integer> map = new HashMap<Integer,Integer>() {
        {
            put(1, 0);
            put(2, 31);
            put(3, 59);
            put(4, 90);
            put(5, 120);
            put(6, 151);
            put(7, 181);
            put(8, 212);
            put(9, 243);
            put(10, 273);
            put(11, 304);
            put(12, 334);
        }
    };

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        while (sc.hasNext()) {
            int year = sc.nextInt();
            int month = sc.nextInt();
            int day = sc.nextInt();
            int sum = map.get(month) + day;
            if ((year % 4 == 0 && year % 100 != 0) || year % 400 == 0) {
                if (month > 2) {
                    sum += 1;
                }
            }
            System.out.println(sum);
        }
    }
}
